﻿@using Model.WeiXin.DTO
@using Model.WXshopBuiness.Enum
@using Model.WXshopBuiness;
@using Xproject.Util
@{
    string Domain = CommonHelper.GetAppSettings("Domain");
    Layout = "~/Views/Shared/_JSlayout.cshtml";    
    ViewBag.Title = "";
    string productId = (string )ViewBag.productId;
}
@model List<ProductSpecification>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=yes" />     
    <link href="~/Content/bootstrap.css" rel="stylesheet" />     
    <link href="~/Content/css/shop/home.css" rel="stylesheet" />
    <link href="http://at.alicdn.com/t/font_l6a0fwucxvzehfr.css" rel="stylesheet" type="text/css" />
    <style>
      

        .item img {
            width: 100%;
            height: 180px;
        }

        .carousel-inner > .item > a > img {
            display: block;
            max-width: 100%;
            line-height: 1;
        }

        .textover {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            font-size: 1.6rem;
        }

        .divmoney {
            color: #fe6e12;
            font-size: 1.457em;
            display: block;
            font-family: '微软雅黑';
            float: left;
        }

        .divqisong {
            display: block;
            margin-top: 1rem;
            margin-left: 7rem;
            font-size: 0.857em;
        }

        .bianjie {
            padding-right: 15px;
            padding-left: 15px;
            margin-right: auto;
            margin-left: auto;
        }

        .browserHistory {
            background: #fff;
            margin-bottom: 5.571em;
        }

        #thelist td {
            font-size: 1em;
        }

        #thelist tr  {
            background: #ffffff;
            color:black;
        }

       
        .personinfo {
            float: left;
            margin-left: 0.5rem;
            margin-top: 0.5rem;
            color: white;
        }

            .personinfo p {
                font-size: 1.2em;
            }
    </style>
</head>
<body>
  <div>
      <button onclick="EditThis('','@(productId)')">新增规格</button>
  </div>
    <div id="wrapper">                  
       <div class="browserHistory " style="margin-bottom:0px;margin-top: 2.8rem;">
                <table class="table">
                    <thead>
                        <tr style="background-color:#8d56e8;color:white;text-align:center">
                            <td>操作</td>
                            <td>规格名称</td>
                            <td>售价</td>
                            <td>标价</td>
                            <td>成本价</td>
                            <td>库存数</td>
                            <td>排序值</td>
                            <td>备注</td>
                        </tr>
                    </thead>
                    <tbody id="thelist">
                        @foreach (ProductSpecification ps in Model)
    {
                        <tr style="text-align:center" id="tr@(ps.ProductSpecificationId)">
                            <td><a onclick="DelThis('@ps.ProductSpecificationId')">删除</a> <a onclick="EditThis('@ps.ProductSpecificationId','@(ps.ProductId)')">编辑</a></td>
                            <td>@ps.SpecificationName</td>
                            <td>@ps.SalesPrice</td>
                            <td>@ps.OrignPrice</td>
                            <td>@ps.CostPrice</td>
                            <td>@ps.Stock</td>
                            <td>@ps.Sort</td>
                            <td>@ps.Remarks</td>
                        </tr>
}
                    </tbody>
                </table>
            </div>                 
    </div>
   
    <script src="~/Scripts/bootstrap.min.js"></script>
    <script src="~/Scripts/shop/index.js"></script>
    <script src="~/Scripts/shop/jquery.min.js"></script>
    <script src="~/Scripts/layer/layer.js"></script>
    <script type="text/javascript">
        function DelThis(ProductSpecificationId) {
             layer.open({
                content: '您确定要删除此规格吗？'
                , btn: ['确定', '不要']
                , yes: function (index) {
                         $.ajax({
                            type: "POST",
                            url: '@(Domain)/WXProduct/DelProductSpec',
                            data: { ProductSpecificationId: ProductSpecificationId  },
                            cache: false,

                            success: function (data) {
                                $("#tr" + ProductSpecificationId).remove();
                                layer.open({
                                    content: data.Data
                                    , skin: 'msg'
                                    , time: 2 //2秒后自动关闭
                                });
                            }
                        });
                }
            });
        }

        function EditThis(ProductSpecificationId,productId) {
                layer.open({
                type: 2,
                title: '编辑产品规格配置',
                shadeClose: true,
                shade: 0.8,
                area: ['1080px', '96%'],
                end: function (index) {
                    //刷新页面
                   // $("#tb_productlist").bootstrapTable('refresh');
                },
                content: '@(Domain)/WXProduct/ProductSpecEdit' + "?SpecificationId=" + ProductSpecificationId + "&productId=" + productId
            });
        }
    </script>
   
</body>

</html>
